#include "stdafx.h"
#include "PositionClass.h"


CPositionClass::CPositionClass(void) : m_fFrameTime(0.0f), m_fYRotation(0.0f), m_fTurnLeftSpeed(0.0f), m_fTurnRightSpeed(0.0f)
{
}


CPositionClass::~CPositionClass(void)
{
}

void CPositionClass::SetFrameTime(float fTime)
{
	m_fFrameTime = fTime;
}

void CPositionClass::GetRotation(float& fRotation)
{
	fRotation = m_fYRotation;
}

void CPositionClass::TurnLeft(bool bIsKeyDown)
{
	if(bIsKeyDown)
	{
		m_fTurnLeftSpeed += m_fFrameTime * 0.01f;

		if(m_fTurnLeftSpeed > (m_fFrameTime * 0.15f))
		{
			m_fTurnLeftSpeed = m_fFrameTime * 0.15f;
		}
	}
	else
	{
		m_fTurnLeftSpeed -= m_fFrameTime * 0.005f;

		if(m_fTurnLeftSpeed < 0.0f)
		{
			m_fTurnLeftSpeed = 0.0f;
		}
	}

	// Update the rotation using the turning speed.
	m_fYRotation -= m_fTurnLeftSpeed;
	if(m_fYRotation < 0.0f)
	{
		m_fYRotation += 360.0f;
	}
}

void CPositionClass::TurnRight(bool bIsKeyDown)
{
	if(bIsKeyDown)
	{
		m_fTurnRightSpeed += m_fFrameTime * 0.01f;

		if(m_fTurnRightSpeed > (m_fFrameTime * 0.15f))
		{
			m_fTurnRightSpeed = m_fFrameTime * 0.15f;
		}
	}
	else
	{
		m_fTurnRightSpeed -= m_fFrameTime* 0.005f;

		if(m_fTurnRightSpeed < 0.0f)
		{
			m_fTurnRightSpeed = 0.0f;
		}
	}

	// Update the rotation using the turning speed.
	m_fYRotation += m_fTurnRightSpeed;
	if(m_fYRotation > 360.0f)
	{
		m_fYRotation -= 360.0f;
	}
}